﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace EQual.MainModule.QualityEvents
{
    /// <summary>
    /// Interaction logic for QualityEventGridView.xaml
    /// </summary>
    public partial class QualityEventGridView : UserControl  ,EQual .Infrastructure .MVPFramework .Views .IListView <object ,object  >
    {
        public QualityEventGridView()
        {
            InitializeComponent();
        }

        private void dataGrid1_RowEditEnding(object sender, Microsoft.Windows.Controls.DataGridRowEditEndingEventArgs e)
        {
            if(this .ItemAdded != null )
            this.ItemAdded(this, new Microsoft.Practices.Composite.Events.DataEventArgs<object>(GetSelectedItem()));
        }

        private void dataGrid1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.ItemSelected != null)
                this.ItemSelected(this, new Microsoft.Practices.Composite.Events.DataEventArgs<object>(GetSelectedItem()));
        }

        public object GetSelectedItem()
        {
            return this.dataGrid1.SelectedItem;
        }

        #region IListView<object,object> Members

        public object Model
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                this.DataContext = value;
            }
        }

        public event EventHandler<Microsoft.Practices.Composite.Events.DataEventArgs<object>> ItemSelected;

        public event EventHandler<Microsoft.Practices.Composite.Events.DataEventArgs<object>> ItemDeleted;

        public event EventHandler<Microsoft.Practices.Composite.Events.DataEventArgs<object>> ItemAdded;

        #endregion
    }
}
